home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / Clueless.swf / scripts / org / flintparticles / initializers / ImageClasses.as next >
Encoding:
Text File  |  2011-10-17  |  2.5 KB  |  96 lines

  1. package org.flintparticles.initializers
  2. {
  3.    import org.flintparticles.emitters.Emitter;
  4.    import org.flintparticles.particles.Particle;
  5.    import org.flintparticles.utils.construct;
  6.    
  7.    public class ImageClasses extends Initializer
  8.    {
  9.        
  10.       
  11.       private var _parameters:Array;
  12.       
  13.       private var _ratios:Array;
  14.       
  15.       private var _images:Array;
  16.       
  17.       public function ImageClasses(param1:Array, param2:Array = null, param3:Array = null)
  18.       {
  19.          var _loc4_:Array = null;
  20.          var _loc5_:int = 0;
  21.          var _loc6_:int = 0;
  22.          var _loc7_:Number = NaN;
  23.          super();
  24.          _images = param1;
  25.          _ratios = new Array();
  26.          _loc4_ = new Array();
  27.          _loc6_ = int(param1.length);
  28.          if(param2 == null)
  29.          {
  30.             _parameters = new Array();
  31.             _loc5_ = 0;
  32.             while(_loc5_ < _loc6_)
  33.             {
  34.                _parameters.push(_loc4_);
  35.                _loc5_++;
  36.             }
  37.          }
  38.          else
  39.          {
  40.             _parameters = param2;
  41.             _loc5_ = int(_parameters.length);
  42.             while(_loc5_ < _loc6_)
  43.             {
  44.                _parameters.push(_loc4_);
  45.                _loc5_++;
  46.             }
  47.          }
  48.          if(param3 != null && param3.length == _loc6_)
  49.          {
  50.             _loc7_ = 0;
  51.             _loc5_ = 0;
  52.             while(_loc5_ < _loc6_)
  53.             {
  54.                _loc7_ += param3[_loc5_];
  55.                _loc5_++;
  56.             }
  57.             _loc5_ = 0;
  58.             while(_loc5_ < _loc6_)
  59.             {
  60.                _ratios.push(param3[_loc5_] / _loc7_);
  61.                _loc5_++;
  62.             }
  63.          }
  64.          else
  65.          {
  66.             _loc5_ = 0;
  67.             while(_loc5_ < _loc6_)
  68.             {
  69.                _ratios.push((_loc5_ + 1) / _loc6_);
  70.                _loc5_++;
  71.             }
  72.          }
  73.       }
  74.       
  75.       override public function initialize(param1:Emitter, param2:Particle) : void
  76.       {
  77.          var _loc3_:Number = NaN;
  78.          var _loc4_:uint = 0;
  79.          var _loc5_:uint = 0;
  80.          _loc3_ = Math.random();
  81.          _loc4_ = _images.length;
  82.          _loc5_ = 0;
  83.          while(_loc5_ < _loc4_)
  84.          {
  85.             if(_ratios[_loc5_] >= _loc3_)
  86.             {
  87.                param2.image = construct(_images[_loc5_],_parameters[_loc5_]);
  88.                return;
  89.             }
  90.             _loc5_++;
  91.          }
  92.          param2.image = construct(_images[_loc4_ - 1],_parameters[_loc4_ - 1]);
  93.       }
  94.    }
  95. }
  96.